<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="css/element.css" rel="stylesheet"/>
    <link href="css/styleindex.css" rel="stylesheet"/>
    <style>
    .el-input__inner{
      border: 0;
      font-size: 1rem;
      text-align: center;
    }.el-input__prefix{
      display: none;
    }
    </style>
</head>
<body style="background: #fff;">

  <div class="mui-content" style="margin-bottom:50px;">
    <div id="vm" class="x-examok" v-cloak>
      <div class="x-header" id="header">
        <div class="x-header-t">任务栏</div>
      </div>
      <!--  -->
      <div class="x-ico-month x-ico-month2">
        <el-date-picker v-model="cardsmonth" type="date" placeholder="选择月" @change="getmonth" format="yyyy 年 MM 月 dd 日" value-format="yyyy-MM-dd" :editable="notkey"></el-date-picker>
      </div>
      <!--  -->
      <template>
        <el-table :data="tableData" style="margin-top:1rem;" @cell-click="gosee">
          <el-table-column label="任务类别" width="" fixed>
            <template slot-scope="scope">
              {{scope.row.title}}
            </template>
          </el-table-column>
          <el-table-column label="未完成" width="70">
            <template slot-scope="scope">
              {{scope.row.un_finish}}
            </template>
          </el-table-column>
          <el-table-column label="进行中" width="70">
            <template slot-scope="scope">
              {{scope.row.underway}}
            </template>
          </el-table-column>
          <el-table-column label="已完成" width="70">
            <template slot-scope="scope">
              {{scope.row.finish}}
            </template>
          </el-table-column>
          <el-table-column label="操作" width="">
            <el-button type="text">查看</el-button>
          </el-table-column>
        </el-table>
      </template>
      <div class="x-task-rate">
        <div class="x-task-t">执行力指数：</div>
        <el-rate v-model="value" disabled show-score text-color="#058142" :colors="ratecolor" :max="10" :allow-half="ishalf"></el-rate>
      </div>
    </div>
  </div>

  <script type="text/javascript" src="./script/vue.js"></script>
  <script type="text/javascript" src="./script/element.js"></script>
  <script type="text/javascript" src="./script/api.js"></script>
  <script type="text/javascript" src="./script/base.js"></script>
	<script>
apiready = function () {
    var iostoph = api.safeArea.top;
    $api.fixStatusBar($api.byId('header'));
    api.setRefreshHeaderInfo({
        loadingImg: 'widget://image/refresh.png',
        bgColor: '#ccc',
        textColor: '#fff',
        textDown: '下拉刷新...',
        textUp: '松开刷新...'
    }, function(ret, err) {
        setTimeout(function(){api.refreshHeaderLoadDone()},500)
        vm.getdata()
    });

    //
    var vm = new Vue({
      el:'#vm',
      data(){
        return{
          value:0,
          ratecolor:['#058142','#058142','#058142','#058142','#058142'],
          ishalf:true,
          tableData:[],
          cardsmonth:'',
          chancedata:'',
          notkey:false,


        }
      },
      created:function() {
        var that=this;


      },
      mounted:function(){
        var that=this;
        //当前月份
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth()+1;
        var day = date.getDate()
        if(month<10){
          month = '' + 0 + month;
        }
        if(day<10){
          day = '' + 0 + day;
        }
        var toMonth = '' + year + '-' + month + '-' + day;
        that.cardsmonth = toMonth;
        that.getdata()
      },
      methods: {
        //
        getdata:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/task/list',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                date:that.cardsmonth
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              // console.log(JSON.stringify(ret));
              if(ret.status == 1){
                that.tableData = ret.data.list;
                that.value = ret.data.implement;

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //
        getmonth:function(val){
          var that = this;
          that.getdata()

        },
        //
        gosee:function(val){
          var that = this;
          // console.log(JSON.stringify(val));
          if(val.type==1||val.type=='1'){//训练考核
            api.openWin({
                name: 'workforcetasklist',
                url: './workforceadmin/workforcetasklist.html',
                pageParam: {
                  type:val.type,
                  timemonth:that.cardsmonth
                }
            });
          }
          if(val.type==2||val.type=='2'){//
            api.openWin({
                name: 'evaluatetasklist',
                url: './evaluatetasklist.html',
                pageParam: {
                  type:val.type,
                  timemonth:that.cardsmonth
                }
            });
          }
          if(val.type==3||val.type=='3'){//
            api.openWin({
                name: 'traintasklist',
                url: './trainadmin/traintasklist.html',
                pageParam: {
                  type:val.type,
                  timemonth:that.cardsmonth
                }
            });
          }
          if(val.type==4||val.type=='4'){//
            api.openWin({
                name: 'meettask',
                url: './meetingadmin/meettask.html',
                pageParam: {
                  type:val.type,
                  timemonth:that.cardsmonth
                }
            });
          }

        },
      }
    })
	}


	</script>
</body>
</html>
